<!DOCTYPE HTML>
<html lang="zh-cn">
<head>
	<meta charset="utf-8" />
	<meta name="renderer" content="webkit|ie-comp|ie-stand" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<title>文章管理</title>
	<link rel="stylesheet" href="/plugins/layui/css/layui.css"  media="all" />
	<!--[if lt IE 9]>
	<script type="text/javascript" src="/plugins/html5shiv.js"></script>
	<script type="text/javascript" src="/plugins/respond.min.js"></script>
	<![endif]-->
	<!--[if IE 6]>
	<script type="text/javascript" src="/plugins/DD_belatedPNG_0.0.8a-min.js" ></script>
	<script>DD_belatedPNG.fix('*');</script>
	<![endif]-->
</head>
<body >
 

<fieldset style="padding:5px;" class="layui-elem-field">
   <div class="layui-form-pane" >
	  	<a th:href="'/essay/textadd/'+${valid }+'/1'" class="layui-btn layui-btn-normal" target="_self">随便写写</a>
	  	<a th:href="'/essay/textadd/'+${valid }+'/2'" class="layui-btn layui-btn-normal" target="_self">MarkDown</a>
	   <button style="float:right;" onclick="location.reload();" class="layui-btn layui-btn-small"><i class="layui-icon">&#x1002;</i></button>
  </div>
</fieldset>

<fieldset style="padding:5px;" class="layui-elem-field">
<div id ="ListForm">
  <form name="textListForm"  id="textListForm" method="post" > 
   <div class="layui-input-inline">
	      <input class="layui-input" placeholder="开始日" id="stime" name="stime" />
    </div>
    <div class="layui-input-inline">
      <input class="layui-input" placeholder="截止日" id="etime"  name="etime"/>
    </div>
    <div class="layui-input-inline"><input style="width:250px;" type="text"  id="title"  name="title" lay-verify="title"  placeholder="请输入标题" class="layui-input" /></div>
    <button class="layui-btn layui-btn-warm"  onclick="search();">检索</button>
    
  <table class="layui-table" lay-even="" lay-skin="row">
  <colgroup>
    <col width="60"/>
    <col width="300"/>
    <col />
    <col width="100"/>
    <col width="100"/>
    <col width="100"/>
    <col width="120"/>
    <col width="180"/>
  </colgroup>
  <thead>
    <tr>
      <th style="text-align:center;">序号</th>
      <th style="text-align:center;">标题</th>
      <th style="text-align:center;">摘要</th>
      <th style="text-align:center;">分类</th>
      <th style="text-align:center;">类型</th>
      <th style="text-align:center;">创建人</th>
      <th style="text-align:center;">创建时间</th>
      <th style="text-align:center;">操作</th>
    </tr> 
  </thead>
  <tbody>
   <tr th:each="row, iterStat :${text_datas}" >
	  <td style="text-align:center;" th:text="${(pageNo-1)*pageSize + iterStat.count }" />
      <td th:text="${row.title }" />
      <td th:text="${row.introduction }" />
      <td th:text="${row.classification.name }" />
      <td th:text="${row.Type.name }" />
	  <td th:text="${row.createuser.name }" />
      <td th:text="${#dates.format(row.createtime,'yyyy-MM-dd')}"  />
      <td style="text-align:center;">
	      <div class="layui-btn-group">
		    <a th:href="'/essay/textview/'+${row.uid }" class="layui-btn layui-btn-small"  target="_blank"><i class="layui-icon">&#xe60a;</i></a>
		    <a th:if="${valid ==0}" th:href="'/essay/textpublish/'+${row.uid }+'/'+${valid }" class="layui-btn layui-btn-small"><i class="layui-icon">&#xe609;</i></a>
		    <a th:href="'/essay/textupdate/'+${row.uid }+'/'+${valid }"  class="layui-btn layui-btn-small"><i class="layui-icon">&#xe639;</i></a>
		    <a th:href="'/essay/textdelete/'+${row.uid }+'/'+${valid }"  class="layui-btn layui-btn-small"><i class="layui-icon">&#xe640;</i></a>
	    </div>
	   </td>	
   </tr>
  </tbody>
</table>  
<input type="hidden" id="uid" name="uid" ></input>
<input type="hidden" id="valid" name="valid"  th:value="${valid }"></input>
<input type="hidden" id="pageNo" name="pageNo" th:value="${pageNo }"></input>
<input type="hidden" id="pageSize" name="pageSize" th:value="${pageSize }"></input>
<input type="hidden" id="itemsCount" name="itemsCount" th:value="${itemsCount }"></input>
<div id="pager"></div>
</form>
</div>
</fieldset>

<script src="/plugins/jquery.1.12.4.min.js" charset="utf-8" />
<script src="/plugins/layui/layui.js" charset="utf-8" />

<script>
var pageNo = parseInt(document.getElementById("pageNo").value);
var pageSize = document.getElementById("pageSize").value;
var itemsCount = document.getElementById("itemsCount").value;

layui.use('laydate', function(){
  var laydate = layui.laydate;
  
  var start = {
    min: '2000-09-23 23:59:59'
    ,max: '2099-06-16 23:59:59'
    ,istoday: false
    ,choose: function(datas){
      end.min = datas; //开始日选好后，重置结束日的最小日期
      end.start = datas //将结束日的初始值设定为开始日
    }
  };
  
  var end = {
 	min: '2000-09-23 23:59:59'
    ,max: '2099-06-16 23:59:59'
    ,istoday: false
    ,choose: function(datas){
      start.max = datas; //结束日选好后，重置开始日的最大日期
    }
  };
  
  document.getElementById('stime').onclick = function(){
    start.elem = this;
    laydate(start);
  }
  document.getElementById('etime').onclick = function(){
    end.elem = this
    laydate(end);
  }
});

layui.use(['laypage', 'layer'], function(){
	  var laypage = layui.laypage
	  ,layer = layui.layer;

	  laypage({
		    cont: 'pager'
		    ,skip: true
		    ,skin: '#1E9FFF'
			,pages: Math.ceil(itemsCount/pageSize) //得到总页数
			,curr: pageNo
			,groups: 5 //连续显示分页数
		    ,jump: function(obj,first){
		    	 if(first!=true){//是否首次进入页面  
		    		goPage(obj.curr)
		    	 }
		    }
		  }); 
}); 

function goPage(pageNo){
	document.getElementById("pageNo").value = pageNo;
	search();
}

function search(){
	document.getElementById("textListForm").target = "_self";
	document.getElementById("textListForm").action = "/essay/textmanagepage";
	document.getElementById("textListForm").submit();
	
// 	$.ajax({
// 		  url: "/essay/textmanagepage",
// 		 // type:"POST",
// 		  data:{
// 			  'valid' : document.getElementById("valid").value,
// 			  'title': document.getElementById("title").value,
// 			  'stime':document.getElementById("stime").value,
// 			  'etime':document.getElementById("etime").value,
// 		  },
// 		  cache: false,
// 		  success: function(){
// 			  $("#ListForm").submit();
// 		  },
// 		  error: function(){
// 			  $("#ListForm").html("获取数据出错！！");
// 		  }
// 		});
	
}
</script>
</body>
</html>